<style lang="less">
    .form-detail-vue {
    .h-panel-body {
        padding-right: 60px;
    }
    .info-basic {
        margin-top: 30px;
        margin-bottom: 30px;
    }
    .info-table {
        margin-top: 30px;
    .h-tabs {
        margin-bottom: 20px;
    }
    }
    .info-title {
        font-size: 16px;
        font-weight: bold;
    }
    .table-wrapper {
        padding: 0 20px;
    }
    }
</style>

<template>
    <div class="users-vue frame-page h-panel form-detail-vue">
        <div class="h-panel h-panel-no-border">
            <div class="h-panel-body">
                <Loading text="读取中" :loading='loading'></Loading>
                <div class="info-title">基本信息</div>
                <!-- 基础信息 -->
                <Form class="info-basic" :label-width="90" mode="threecolumn">
                   <#list table.fields as field>
                      <#if field.propertyName == "name">

                    <FormItem label="${field.comment}">
                        <input type="text" v-model="data.${field.propertyName}" />
                    </FormItem>
                      </#if>
                   </#list>
                </Form>


                <div class="info-title">其他信息</div>
                <!-- 其他信息 -->
                <Form class="info-basic" :label-width="90" mode="twocolumn">
                   <#list table.fields as field>
                       <#if field.propertyName != "name">
                      <FormItem label="${field.comment}">
                          <input type="text" v-model="data.${field.propertyName}" />
                      </FormItem>
                       </#if>
                   </#list>
                </Form>
                <!-- 保存按钮 -->
                <div class="text-center">
                    <Button color="primary" @click="save">保存</Button>
                    <Button @click="reset">重置</Button>
                </div>
            </div>
        </div>
    </div>

</template>
<script>

//初始化请求参数列表
function initParams() {
    return {
   <#list table.commonFields as field>
       <#if field.propertyName == "name">
           ${field.propertyName}: null
       </#if>
   </#list>
   <#list table.fields as field>
       ${field.propertyName}: null,
   </#list>
    };
}

export default {
    data() {
        return {
            loading: false,
            data: initParams()
        };
    },
    methods: {
        save() {
            this.loading = true; //开启模块load动画
            R.${entity}.add(this.data).then(resp => {
                if (resp.ok) {
                this.$Message("新增成功");
                this.reset();
            }
            this.loading = false; //关闭模块load动画
        });
        },
        reset() {
            this.data = initParams();
        },
    }
};
</script>
